<template>
  <div>
    <h2>优惠券的录入</h2>
    <table border="1">
      <tr>
        <td>优惠券标题</td>
        <td>
          <input type="text" v-model="state.title">
        </td>
      </tr>
      <tr>
        <td>剩余库存</td>
        <td>
          <input type="text"  v-model="state.num">
        </td>
      </tr>
      <tr>
        <td>每人限购</td>
        <td>
          <input type="text"  v-model="state.people">
        </td>
      </tr>
      <tr>
        <td>门店昵称</td>
        <td>
          <select v-model="state.tYpe">
            <option>请选择</option>
            <option>八维顺义门店</option>
            <option>昌平学院</option>
          </select>
        </td>
      </tr>
      <tr>
        <td>消费满多少</td>
        <td>
          <input type="text"  v-model="state.price">
        </td>
      </tr>
      <tr>
        <td>优惠券减去金额</td>
        <td>
          <input type="text"  v-model="state.jPrice">
        </td>
      </tr>
      <tr>
        <td>优惠券使用时间</td>
        <td>
          <input type="date"  v-model="state.sdate">
        </td>
      </tr>
      <tr>
        <td>优惠券过期时间</td>
        <td>
          <input type="date"  v-model="state.edate">
        </td>
      </tr>
      <tr>
        <td>业务</td>
        <td>
          <input type="text"  v-model="state.yewu">
        </td>
      </tr>
      <tr>
        <td>联系电话</td>
        <td>
          <input type="text"  v-model="state.phone">
        </td>
      </tr>
      <tr>
        <td>详情</td>
        <td>
          <input type="text"  v-model="state.xiagqing">
        </td>
      </tr>
      <tr>
        <td>状态</td>
        <td>
          <input type="text"  v-model="state.states">
        </td>
      </tr>
      
      <tr>
        <td></td>
        <td>
          <input type="button" @click="add" value="添加">
        </td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import { reactive,toRefs,onMounted } from 'vue';
import axios from 'axios';
import { useRoute,useRouter } from 'vue-router';
let route=useRoute();
let router=useRouter();
let data=reactive({
  state:{
    title:'',
    num:'',
    people:'',
    tYpe:'',
    price:'',
    jPrice:'',
    sdate:'',
    edate:'',
    yewu:'',
    phone:'',
    xiagqing:'',
    states:''
  }
})
let {state}=toRefs(data)


function add()
{
  let obj={
  "title": state.value.title,
  "num": state.value.num,
  "people": state.value.people,
  "tYpe": state.value.tYpe,
  "price": state.value.price,
  "jPrice": state.value.jPrice,
  "sdate": state.value.sdate,
  "edate": state.value.edate,
  "yewu": state.value.yewu,
  "phone": state.value.phone,
  "xiagqing":state.value.xiagqing,
  "states": state.value.states
  }
  
 
  axios({
    url:'/api/MenDian/Prick',
    method:'post',
    data:obj
  })
  .then(res=>{
    if(res.data.data==1)
  {
    alert("添加成功")
    router.push("../pshow")
  }
else
{
  alert("添加失败")
}
  })
  .catch(err=>{

  })
}
</script>

<style scoped>

</style>